import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.dart';
import 'package:xvideos/assets_tool/images.dart';
import 'package:xvideos/hj_model/video_model.dart';
import 'package:xvideos/hj_utils/widget_utils.dart';

import '../../tools_base/global_store/store.dart';
import '../../hj_utils/global.dart';
import '../video/share_video_dialog.dart';

class ShareBottomSheet extends StatelessWidget {
  final VideoModel? videoModel;

  const ShareBottomSheet({super.key, this.videoModel});

  bool get isVideo => videoModel?.sourceURL?.isNotEmpty == true;

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.fromLTRB(16, 32, 16, 32),
      decoration: BoxDecoration(
        color: Color(0xff141414),
        borderRadius: BorderRadius.vertical(
          top: Radius.circular(18),
        ),
      ),
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: [
          Row(
            children: [
              Text(
                isVideo ? '分享视频给好友,当一个称职的老司机' : "",
                style: TextStyle(color: Colors.white, fontSize: 14),
              ),
              Spacer(),
              InkWell(
                child: Icon(
                  Icons.close,
                  color: Colors.white,
                  size: 22,
                ),
                onTap: () => Get.back(),
              )
            ],
          ),
          12.sizeBoxH,
          if (isVideo)
            GestureDetector(
              behavior: HitTestBehavior.deferToChild,
              onTap: () async {
                Get.dialog(ShareVideoDialog(videoModel: videoModel), useSafeArea: false);
              },
              child: Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  18.sizeBoxH,
                  Image.asset(
                    "link_logo.webp".commonImgPath,
                    width: 60,
                    height: 60,
                  ),
                  12.sizeBoxH,
                  Row(
                    mainAxisSize: MainAxisSize.min,
                    children: [
                      Text(
                        '${isVideo ? "视频" : "文章"}链接',
                        style: TextStyle(
                          color: Colors.white,
                          fontSize: 14,
                          fontWeight: FontWeight.w500,
                        ),
                      ),
                      1.sizeBoxW,
                      Image.asset(
                        "play_icon_small.png".commonImgPath,
                        width: 20,
                        height: 20,
                      ),
                    ],
                  ),
                  30.sizeBoxH,
                ],
              ),
            ),
          Container(
            alignment: isVideo ? Alignment.topLeft : Alignment.topCenter,
            child: Text(
              '分享APP给好友,每邀请1人,送1天VIP',
              style: TextStyle(
                color: Colors.white,
                fontSize: 16,
                fontWeight: FontWeight.w500,
              ),
            ),
          ),
          30.sizeBoxH,
          InkWell(
            onTap: () {
              Clipboard.setData(ClipboardData(text: globalStore.getMe()?.promoteURL ?? ""));
              showToast("复制成功，快去分享吧");
            },
            child: Image.asset(
              "link_logo_2.webp".commonImgPath,
              width: 60,
              height: 60,
            ),
          ),
          4.sizeBoxH,
          Text(
            'APP下载链接',
            style: TextStyle(
              color: Colors.white,
              fontSize: 14,
              fontWeight: FontWeight.w500,
            ),
          ),
        ],
      ),
    );
  }
}
